<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/admin.css'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/main.css'); ?>">
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/jquery-1.3.2.min.js?v=1.3.2'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('skin/xheditor/xheditor.min.js?v=1.0.0-final'); ?>"></script>
<script	type="text/javascript">
var introeditor;
$(function(){
	introeditor=$("#shop_intro").xheditor({skin:'vista',tools:"Cut,Copy,Paste,Pastetext,Separator,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,Separator,Align,List,Outdent,Indent,Separator,Link,Unlink,Img,Table,Separator,Source,Fullscreen,About"});

});
</script>
<style>
td span {color:red;}
</style>
</head>
<body>

<div id="maincontent">
<psp:tags     htmlname='messagebox'  iconname='messagebox' />
	<div class="wrap">
	<div class="crumbs">当前位置 &gt;&gt; 商铺管理 &gt;&gt; 修改商铺</div>
        <hr />
	<div class="infobox">
<h3><span class="left">修改商铺</span> <span style=" margin-right:15p;" class="right"><a href="<?php echo $this->_url('admin/shop/index');?>">会员列表</a>&nbsp;&nbsp;</span></h3>
			<div class="content2">
				<form method="post" action="<?php echo $this->_url('admin/shop/shopedit');?>"	name="form_shop_request" onsubmit="return checkForm()">
					<table>
						<tr>
							<td width="140px;">店铺名称：</td>
							<td><input type="text" name="shop_name"	value="<?php echo $shop_info['shop_name']; ?>" style="width: 250px;" maxlength="50" /><span class="red">*</span></td>
						</tr>
						<input type="hidden" name="shop_id" value="<?php echo $shop_info['id']; ?>" />
						<tr>
							<td>店铺分类：</td>
							<td>
							<span id="shop_country">
								<select name="data[shopinfo][categories_parent]" onchange="categorieschanged(this.value)">
									<option value='0'>选择分类</option>
									<?php  foreach($shop_categories_parent as $v) {?>
										<option value="<?php echo  $v['shopcategories']['id'];?>"
											<?php  if($v['shopcategories']['id']==$categories_parent){echo 'selected';}?>><?php echo  $v['shopcategories']['cat_name'];?></option>
									<?php }?>
								</select>
							</span>
							<span id="shop_categories">
	
							</span>						
						<span class="red">*</span>
								</td>
						</tr>
						<tr>
							<td>所在地区：</td>
							<td>
								<span id="user_country">
								<select name="data[shopinfo][shop_country]" onchange="areachanged(this.value,0);">
									<option value='0'>选择国家</option>
								 <?php   foreach($areas_info[0] as $v){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$shop_info['shop_country']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php }?>
								</select>
								</span>
								
								<span id="user_province"><?php  if($shop_info['shop_country']){?>
								<select name="data[shopinfo][shop_province]" onchange="areachanged(this.value,1);">
									<option value='0'>选择省份</option>
								<?php foreach($areas_info[1] as $v) {
										if($v['parent_id'] == $shop_info['shop_country']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$shop_info['shop_province']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
								
								<span id="user_city">
								<?php 	 if($shop_info['shop_province']){?>
								<select name="data[shopinfo][shop_city]" onchange="areachanged(this.value,2);">
									<option value='0'>选择城市</option>
								    <?php foreach($areas_info[2] as $v) {
										if($v['parent_id'] == $shop_info['shop_province']){?>
									<option value="<?php echo  $v['id'];?>" <?php  if($v['id']==$shop_info['shop_city']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?></select>
								<?php }?>
								</span>
								
								<span id="user_district">
								<?php  if($shop_info['shop_city']) {?>
								<select name="data[shopinfo][shop_district]">
									<option value='0'>选择地区</option>
								<?php foreach($areas_info[3] as $v) {
										if($v['parent_id'] == $shop_info['shop_city']){?>
									<option value="<?php echo  $v['id'];?>" <?php   if($v['id']==$shop_info['shop_district']){echo 'selected';}?>><?php echo  $v['area_name'];?></option>
								<?php 	}
								}?>
								</select>
								<?php }?>
								</span>
						<span class="red">*</span>
								</td>
						</tr>
						<tr>
							<td>详细地址：</td>
							<td><input type="text" name="shop_address"
			value="<?php echo $shop_info['shop_address']; ?>"
			style="width: 250px;" maxlength="200" /> <span class="red">*</span></td>
						</tr>
						<tr>
							<td>经营范围：</td>
							<td><input type="text" name="shop_management"
			value="<?php echo $shop_info['shop_management']; ?>"
			style="width: 250px;" maxlength="200" /> <span class="red">*</span></td>
						</tr>
<?php
$shoptemplate_arr[] = array(
	'imgurl' => 'skin/default/images/default_small.gif',
	'bigimgurl' => 'skin/default/images/default.gif',
	'tpltag' => 'default',
	'tplname' => '默认模板'
);

?>							
						<tr>
							<td>选择模板：</td>
							<td class="templageimg"><?php 
				foreach($shoptemplate_arr as $v){
					?>
								<span><img style="border:2px solid #FFF" src="<?php echo $v['imgurl']; ?>" width="95"	alt="<?php echo $v['tplname']; ?>"	onclick="wshowimg('<?php echo $v['bigimgurl']; ?>')" onmouseover="imgmover(this)" onmouseout="imgmout(this)" onerror="this.src='<?php echo $this->_webroot('images/nopic.gif'); ?>'" /><br />
								<input type="radio" name="shop_template"	value="<?php echo $v['tpltag']; ?>"	<?php if($shop_info['shop_template']==$v['tpltag']){echo 'checked';}?> /> <?php echo $v['tplname']; ?></span>
								<?php
				}
				?></td>
						</tr>
						<tr>
							<td>店铺简介：</td>
							<td><textarea name="shop_intro" id="shop_intro" cols="75" rows="15"><?php echo $shop_info['shop_intro']; ?></textarea></td>
						</tr>
						<tr>
							<td colspan="2"><span class="button-container"><input class="regular-button" type="submit" name="btn_submit"
			value="修改商品" /></span></td>
						</tr>
					</table>
				</form>
			</div>
			
	 </div>
	</div>
</div>
<div id="showimg" style="display:none; width:408px; text-align:center; border:5px solid #F6A248; position:absolute; padding:4px; background:#fff; top:200px;"><img id="imgsrc" src="" width="400" /></div>
<div style="width:0px; height:0px; overflow:hidden;"><input type="input" id="hiddeninput" onblur="whideimg()" /></div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js'); ?>"></script>
<script language="JavaScript">
<!--
categorieschanged(<?php echo $categories_parent ?>,<?php echo $categories_child ?>);

var utype = '';
function areachanged(value,type){
	if(value > 0) {	
		ajax("<?php echo $this->_url('admin/shop/getareas');?>","POST","value="+value+"&mode=shopinfo&pre=shop_&type="+type,function(return_text){
			var return_text = return_text.replace(/[\n\r]/g,"");
			if(return_text==""){
				alert("请重新选择!！");
			} else {
				if(type==0) {
					document.getElementById("user_province").innerHTML = return_text;
					show("user_province");
					hide("user_city");
					hide("user_district");
				} else if(type==1) {
					document.getElementById("user_city").innerHTML = return_text;
					show("user_city");
					hide("user_district");
				} else if(type==2) {
					document.getElementById("user_district").innerHTML = return_text;
					show("user_district");
				}
			}
		});
	} else {
		if(type==2) {
			hide("user_district");
		} else if(type==1) {
			hide("user_district");
			hide("user_city");
		} else if(type==0) {
			hide("user_district");
			hide("user_city");
			hide("user_province");
		}
	}
}


function categorieschanged(value,child_value){
	if(value > 0) {
		ajax("<?php echo $this->_url('admin/shop/getshopcategories');?>","POST","mode=shopinfo&value="+value+"&child_value="+child_value,function(return_text){
			return_text = return_text.replace(/[\n\r]/g,"");
			document.getElementById("shop_categories").innerHTML = return_text;
			show("shop_categories");
		});
	}
}

function hide(id) {
	document.getElementById(id).style.display = 'none';
}
function show(id) {
	document.getElementById(id).style.display = '';
}

function checkForm() {
var shop_name = document.getElementsByName("shop_name")[0];
var shop_address = document.getElementsByName("shop_address")[0];
var shop_management = document.getElementsByName("shop_management")[0];
if(shop_name.value=='') {
alert("店铺名称不能为空！");
shop_name.focus();
return false;
} else if(document.getElementsByName("country")[0].value==0) {
alert("请选择国家！");
return false;
} else if(document.getElementsByName("province")[0].value==0) {
alert("请选择省份！");
return false;
} else if(document.getElementsByName("city")[0].value==0) {
alert("请选择城市！");
return false;
} else if(document.getElementsByName("district")[0].value==0) {
alert("请选择地区！");
return false;
} else if(shop_address.value=='') {
alert("详细地址不能为空！");
shop_address.focus();
return false;
} else if(shop_management.value=='') {
alert("主要经营范围不能为空！");
shop_management.focus();
return false;
}
return true;
} 

function imgmover(obj) {
	obj.style.border = '2px solid #E38016';
}

function imgmout(obj) {
	obj.style.border = '2px solid #eee';
}

function wshowimg(v) {
	var width = document.body.clientWidth;
	var showimg = document.getElementById("showimg");
	var imgsrc = document.getElementById("imgsrc");

	var left = "100";
	if(width) {
		left = (width-400)/2;
	}
	showimg.style.left = left+"px";
	showimg.style.display = '';
	imgsrc.src = v;
	document.getElementById("hiddeninput").focus();
}

function whideimg() {
	var showimg = document.getElementById("showimg");
	showimg.style.display = 'none';
}
//-->
</script>
</body>
</html>